package com.lemurian.bankdata.lite.enums;

public enum UserRole {
	
	SUPER_ADMIN("SA"),
    ADMINISTRATOR("AD"),
    ;
    private String code;

    UserRole(String code) {
        this.code = code;
    }

    public String value() {
        return code;
    }

    public static UserRole lookup(String id) {
        UserRole[] listUt = UserRole.values();
        for(UserRole ut : listUt) {
            if(id.equals(ut.value()))
                return ut;
        }
        return null;
    }

    public static UserRole lookupName(String name) {
        UserRole[] listUt = UserRole.values();
        for(UserRole ut : listUt) {
            if(ut.name().equals(name))
                return ut;
        }
        return null;
    }

    public static boolean atLeastSuperAdmin(UserRole role) {
        if(role.name().equals(SUPER_ADMIN.name()))
            return true;
        return false;
    }

    public static boolean atLeastAdministrator(UserRole role) {
        if(role.name().equals(ADMINISTRATOR.name()) || role.name().equals(SUPER_ADMIN.name()))
            return true;
        return false;
    }

}
